package com.xbongbong.pro.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;


/**
 * @Author mingliang
 * @Description 精线索工商查询对应枚举
 **/
@Getter
public enum BusinessFineClueEnum {

    /**
     * 工商查询匹配字段 参考文档：
     */
    ENTERPRISE_NAME(1, "enterpriseName","enterpriseName", "企业名称", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    HISTORY_NAME(2,"historyName","historyName", "历史名称", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    LEGAL_REPRESENTATIVE(3,"legalRepresentative","legalRepresentative", "法人代表", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

//    LEGAL_REPRESENTATIVE_TYPE(4,"legalRepresentativeType","legalRepresentativeType", "法人代表类型", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    DATE_OF_ESTABLISHMENT(5,"dateOfEstablishment","dateOfEstablishment", "成立日期", FieldTypeEnum.DATETIME.getType(), 0, "FineClueInfo"),

    REGISTRATION_NUMBER(6,"registrationNumber","registrationNumber", "注册号", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    UNIFY_SOCIAL_CREDIT_CODE(7,"unifySocialCreditCode","unifySocialCreditCode", "统一社会信用代码", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    ENTERPRISE_TYPE(8,"enterpriseType","enterpriseType", "企业类型", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    REGISTERED_CAPITAL(9,"registeredCapital","registeredCapital", "注册资金", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    PROVINCE_CITY(10,"provinceCity","provinceCity", "省市", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    REGISTRATION_AUTHORITY(11,"registrationAuthority","registrationAuthority", "登记机关", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    CANCELLATION_DATE(12,"cancellationDate","cancellationDate", "注销日期", FieldTypeEnum.DATETIME.getType(), 0, "FineClueInfo"),

    APPROVAL_DATE(13,"approvalDate","approvalDate", "核准日期", FieldTypeEnum.DATETIME.getType(), 0, "FineClueInfo"),

    OPERATING_STATE(14,"operatingState","operatingState", "经营状态", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    ORGANIZATION_CODE(15,"organizationCode","organizationCode", "组织机构代码", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    ANNUAL_TURNOVER(16,"annualTurnover","annualTurnover", "年营业额", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    //精线索字段operatingPeriod:"2020-10-10-2020-20-20"--拆分为OPERATING_PERIOD_START，OPERATING_PERIOD_END
    OPERATING_PERIOD_START(17,"operatingPeriodStart","operatingPeriodStart", "营业期限自", FieldTypeEnum.DATETIME.getType(), 0, "FineClueInfo"),

    OPERATING_PERIOD_END(18,"operatingPeriodEnd","operatingPeriodEnd", "营业期限至", FieldTypeEnum.DATETIME.getType(), 0, "FineClueInfo"),

    BUSINESS(19,"business","business", "所属行业", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    MAILING_ADDRESS(20,"mailingAddress","mailingAddress", "通讯地址", FieldTypeEnum.TEXT.getType(), 0, "FineClueInfo"),

    REGISTERED_ADDRESS(21,"registeredAddress","registeredAddress", "注册地址", FieldTypeEnum.ADDRESS.getType(), 0, "FineClueInfo"),

    SCOPE_OF_BUSINESS(22,"scopeOfBusiness","scopeOfBusiness", "经营范围", FieldTypeEnum.TEXTAREA.getType(), 0, "FineClueInfo"),

    SHAREHOLDER(23,"shareholder","shareholder", "股东", FieldTypeEnum.SUB_FORM.getType(), 0, "FineClueInfo"),

    SHAREHOLDER_NAME(24,"inv","inv", "股东名", FieldTypeEnum.TEXT.getType(), 23, "FineClueInfo"),

    SHAREHOLDER_TYPE(25,"invType","invType", "股东类型", FieldTypeEnum.TEXT.getType(), 23, "FineClueInfo"),

    SECURITYSIZE(26,"securitySize","securitySize","参保人数",FieldTypeEnum.TEXT.getType(),0,"FineClueInfo"),
    ;

    /**
     * 字段id
     */
    private Integer code;

    /**
     * 字段变量名
     */
    private String attr;

    /**
     * 字段别名
     */
    private String alias;

    /**
     * 字段名称
     */
    private String attrName;

    /**
     * 字段类型
     */
    private Integer fieldType;

    /**
     * 字段是否是属于子表单中的，目前只有子表单中的字段parent不为0
     */
    private Integer parent;

    /**
     * 来源
     */
    private String source;

    BusinessFineClueEnum(Integer code, String attr, String alias, String attrName, Integer fieldType, Integer parent, String source) {
        this.code = code;
        this.attr = attr;
        this.alias = alias;
        this.attrName = attrName;
        this.fieldType = fieldType;
        this.parent = parent;
        this.source = source;
    }

    public static List<BusinessFineClueEnum> getByParentId(Integer code) {
        List<BusinessFineClueEnum> list = new ArrayList<>(10);
        for (BusinessFineClueEnum businessSearchEnum : values()) {
            if (Objects.equals(code, businessSearchEnum.getParent())) {
                list.add(businessSearchEnum);
            }
        }
        return list;
    }

    public static BusinessFineClueEnum getByCode(Integer code) {
        for (BusinessFineClueEnum businessSearchEnum : values()) {
            if (Objects.equals(code,businessSearchEnum.getCode())) {
                return businessSearchEnum;
            }
        }
        return null;
    }
}
